import { listApprovalUser } from "@/api/yybl/jinkulist";
import { listdecisionPoint } from "@/api/yybl/decision";
import { listscene, listsceneName } from "@/api/yybl/riskScene";
import { totalPaimingList } from "@/views/xinren/riskmodel/integration/data.js";
// import { getVpncomputers } from "@/api/operationIp/vpnDevice";
const state = {
  persons: [],
  sceneNameList: [],
  playerList: totalPaimingList.map((i) => ({
    value: i.playerName,
    label: i.playerName,
  })),
  betmoneyList: [
    {
      value: "0",
      label: "0",
    },
    {
      value: "5",
      label: "5元",
    },
  ],
  resultsList: [
    {
      value: "2",
      label: "无果",
    },
    {
      value: "0",
      label: "失败",
    },
    {
      value: "1",
      label: "成功",
    },
  ],
  psyqualityList: [
    {
      value: "-5",
      label: "-5",
    },
    {
      value: "-10",
      label: "-10",
    },
    {
      value: "-20",
      label: "-20",
    },
    {
      value: "0",
      label: "0",
    },
    {
      value: "5",
      label: "5",
    },
    {
      value: "10",
      label: "10",
    },
    {
      value: "20",
      label: "20",
    },
  ],
  sceneTypeList: [
    {
      label: "实时监控",
      value: "1",
    },
    {
      label: "历史行为分析",
      value: "2",
    },
  ],
  sceneList: [
    {
      label: "异常时间登录",
      value: "0",
    },
    {
      label: "异常IP登录",
      value: "1",
    },
  ],
  ruleTypeList: [
    // {
    //   label: "完全匹配",
    //   value: "0",
    // },
    {
      label: "频次匹配",
      value: "1",
    },
    // {
    //   label: "区间匹配",
    //   value: "2",
    // },
  ],
  riskFieldList: [
    {
      label: "IP属性",
      value: "0",
    },
    {
      label: "时间属性",
      value: "1",
    },
  ],
  cycleValList: [
    {
      label: "月",
      value: "0",
    },
    {
      label: "周",
      value: "1",
    },
    {
      label: "日",
      value: "2",
    },
  ],
  realcycleValList: [
    {
      label: "1分钟",
      value: "3",
    },
    {
      label: "2分钟",
      value: "4",
    },
    {
      label: "3分钟",
      value: "5",
    },
    {
      label: "5分钟",
      value: "6",
    },
    {
      label: "10分钟",
      value: "7",
    },
    {
      label: "60分钟",
      value: "8",
    },
  ],
  xinrenList: [
    {
      label: "用户",
      value: "1",
    },
    // {
    //   label: "终端",
    //   value: "2",
    // },
    // {
    //   label: "资产",
    //   value: "3",
    // },
  ],
  strategyList: [
    {
      label: "命名策略",
      value: "0",
    },
    {
      label: "密码策略",
      value: "1",
    },
    {
      label: "登录策略",
      value: "2",
    },
    {
      label: "访问策略",
      value: "3",
    },
    {
      label: "验证策略",
      value: "4",
    },
  ],
  trustLevelList: [
    {
      label: "高",
      value: "1",
    },
    {
      label: "中",
      value: "2",
    },
    {
      label: "低",
      value: "3",
    },
  ],
  trustTypeList: [
    {
      label: "用户",
      value: "1",
    },
    {
      label: "终端",
      value: "2",
    },
    {
      label: "资产",
      value: "3",
    },
  ],
  decisionPointList: [],
  riskLevelList: [
    {
      label: "高",
      value: "1",
    },
    {
      label: "中",
      value: "2",
    },
    {
      label: "低",
      value: "3",
    },
  ],
};
const mutations = {
  setPersondatas: (state, data) => {
    state.persons = data;
  },
  setdecisionPointList: (state, data) => {
    state.decisionPointList = data.map((i) => ({
      value: i.id,
      label: i.decisionName,
    }));
  },
  setsceneList: (state, data) => {
    state.sceneList = data.map((i) => ({
      value: i.id + "",
      label: i.sceneName,
      sceneType: i.sceneType,
    }));
  },
  setsceneNameList: (state, data) => {
    state.sceneNameList = data.map((i) => ({
      value: i.id + "",
      label: i.sceneName,
    }));
  },
};

const actions = {
  async getPersondatas({ commit }) {
    try {
      let params = {};
      const res = await listApprovalUser(params);
      if (res && res.rescode === 200) {
        commit("setPersondatas", res.data);
      } else {
        commit("setPersondatas", []);
      }
    } catch (error) {
      commit("setPersondatas", []);
    }
  },
  async getdecisionPointList({ commit }) {
    try {
      let params = {};
      const res = await listdecisionPoint(params);
      if (res && res.rescode === 200) {
        commit("setdecisionPointList", res.data.dataList);
      } else {
        commit("setdecisionPointList", []);
      }
    } catch (error) {
      commit("setdecisionPointList", []);
    }
  },
  async getsceneList({ commit }) {
    try {
      let params = {};
      const res = await listscene(params);
      if (res && res.rescode === 200) {
        commit("setsceneList", res.data.dataList);
      } else {
        commit("setsceneList", []);
      }
    } catch (error) {
      commit("setsceneList", []);
    }
  },
  async getsceneNameList({ commit }) {
    try {
      let params = {};
      const res = await listsceneName(params);
      console.log(res.data);
      if (res && res.rescode === 200) {
        commit("setsceneNameList", res.data);
      } else {
        commit("setsceneNameList", []);
      }
    } catch (error) {
      commit("setsceneNameList", []);
    }
  },
};
export default {
  namespaced: true,
  state,
  mutations,
  actions,
};
